Skip to main content

Origin Error Caching

(MI.NegativeCachePolicy)

Overview

Use the Origin Error Caching feature to set conditions for caching specified error response codes from the origin server.

A server error (such as a 5xx server error) typically implies a temporary issue that might persist for a certain duration. You can use Origin Error Caching (also known as negative caching) to avoid sending repetitive requests to the origin server during this time, thus reducing the load on the origin server and also providing a quicker response to the client.

Note the following:

  • By default, origin error caching policies in the HTTP response from the origin override the CDN error caching policies defined by this feature.
  • By default, the error caching policies specified by the rule are used only when there is no error caching policy specified in the response.
  • However, you can set force-internal to true so that the CDN error caching policies override error caching specified in the origin response.

You can configure this rule at the site, host, or path level.

info

Error code caching (also known as negative caching) permits storing error codes for a specific duration (x amount of seconds).

During the period when error code caching is active, subsequent requests for a particular URL are not sent to the origin. Any end user requesting the URL will automatically receive the cached status code.

The purpose of error code caching is to allow the origin sufficient time to recover before the CDN attempts another request for the same URL.


Example

This example configures the following error caching (negative cache) policies for error-codes 400 and 500.

{
"generic-metadata-type": "MI.NegativeCachePolicy",
"generic-metadata-value": {
"cache-policy": {
"internal": "4",
"external": "as-is",
"force-internal": true,
"force-external": false
},
"error-codes": [
"400",
"500"
]
}
}

  • "internal": "4": These errors will be cached for 4 seconds.
  • "force-internal": true: The CDN error caching settings override any error caching settings in the origin response.
  • "force-external": false; "external": "as-is": No client error caching behavior is specified.

Note that "internal" represents the CDN error caching behavior, while "external" represents the client error caching behavior.

Supported Properties

FieldDescriptionValid Values
internalThe CDN error caching policy. Specify the number of seconds to cache errors on the CDN, or specify a different behavior.- <number of seconds>
- as-is: No CDN error caching settings are specified.
- no-cache: Revalidate with the origin before serving the cached error.
- no-store: Send all requests to the origin. Do not cache errors.
externalThe client error caching policy. Specify the number of seconds to cache errors on the client, or specify a different behavior.- <number of seconds>
- as-is: Use the TTL parameters defined in the HTTP response from the origin.
- no-cache: Revalidate with the origin before serving the cached error.
- no-store: Send all requests to the origin. Do not cache errors.
force-internalDetermines if the error caching policy set by the CDN (internal) overrides any error caching policy set by the origin.true, false
force-externalDetermines if the error caching policy set by the client (external) overrides any error caching policy set by the origin.true, false